package com.xiaoquan.graphql.resolver;

import com.coxautodev.graphql.tools.GraphQLResolver;
import com.xiaoquan.graphql.entity.Author;
import com.xiaoquan.graphql.entity.Book;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;

public class AuthorResolver implements GraphQLResolver<Author> {

    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");


    public String getCreatedTime(Author author) {
        return sdf.format(author.getCreatedTime());
    }

    public List<Book> getBooks(Author author) {
        Book book = new Book();
        book.setAuthorId(1111L);
        book.setIsbn("No");
        book.setPageCount(99);
        book.setTitle("test");

        return Arrays.asList(book);
    }
}
